package gherkinedit.wizard;

import gherkinedit.templatesystem.Template;
import gherkinedit.templatesystem.XMLHandler;
import org.eclipse.jface.wizard.Wizard;

public class CreateTemplateWizard extends Wizard {

	protected CreateTemplateWizardPage1 page1;

	public CreateTemplateWizard() {
		super();
		setNeedsProgressMonitor(true);
		setWindowTitle("Create New Template");
	}

	@Override
	public void addPages() {
		page1 = new CreateTemplateWizardPage1();
		addPage(page1);
	}

	@Override
	public boolean performFinish() {
		// Create template and save it as XML in a file
		Template template = new Template(page1.getTemplateName(), page1.getTemplateRegex());
		XMLHandler.saveTemplate(template);
		// Print the result to the console
		System.out.println("Template Name: " + page1.getTemplateName());
		System.out.println("Template Regex: " + page1.getTemplateRegex());
		return true;
	}
}